package com.yanyeori.nacosconfig.controller;

import com.yanyeori.framework.core.model.WebResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author chenkuan
 * @desc
 * @date 2021/3/23 023 16:12
 */
@RestController
@RequestMapping("/testController")
@RefreshScope //自动刷新配置
public class TestController {
    private final Logger logger = LoggerFactory.getLogger(getClass());

    @Value("${nacos.name}")
    private String name;

    @RequestMapping(value = "/test", method = {RequestMethod.GET, RequestMethod.POST})
    public WebResponse test() {
        logger.info("name: {}", name);
        return WebResponse.ok().data(name);
    }
}
